#include <stdio.h>

int main() {
	int a, b;
	scanf("%d %d", &a, &b);
	int m[a];
	for (int i = 0; i < a; i++) {
		scanf("%d", &m[i]);
	}
	int n[b];
	for (int i = 0; i < b; i++) {
		scanf("%d", &n[i]);
	}

	int num[a + b];
	int p1 = 0, p2 = 0, p3 = 0;
	while (p1 < a && p2 < b) {
		if (m[p1] < n[p2]) {
			num[p3] = m[p1];
			p1++;
			p3++;
		} else if (m[p1] > n[p2]) {
			num[p3] = n[p2];
			p2++;
			p3++;
		} else {
			num[p3] = m[p1];
			p3++;
			num[p3] = n[p2];
			p3++;
		}
	}
	if (p1 < a) {
		for (int i = p1; i < a; i++) {
			num[p3] = m[p1];
			p1++;
			p3++;
		}
	} else {
		for (int i = p2; i < b; i++) {
			num[p3] = n[p2];
			p2++;
			p3++;
		}
	}
	for (int i = 0; i < a + b; i++) {
		printf("%d ", num[i]);
	}
	return 0;
}